package con.shopping.entity;

import java.util.Date;
import java.util.List;

/**
 * @author ：河神
 * @date ：Created in 2022/2/14 8:54 下午
 */
public class GoodDP {


    private Goods goods;
    /**
     *
     */
    private List<Discount> discounts;

    public double getPrice(int num){
        return getPrice()*num;
    }

    public double getPrice(){
        for (Discount discount : discounts) {
            if (discount.effective(new Date())){
                return discount.discountAmount(goods.getPrice());
            }
        }
        return goods.getPrice();
    }
}
